package com.xyht.sca_s.student_manage_system.modules.assetFixedSelfInspection.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.assetFixedSelfInspection.entity.req.SmsAssetSelfInspectionDetailReq;
import com.xyht.sca_s.student_manage_system.modules.assetFixedSelfInspection.entity.req.SmsAssetSelfInspectionPlanFinishReq;
import com.xyht.sca_s.student_manage_system.modules.assetFixedSelfInspection.service.SmsAssetSelfInspectionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 我的资产 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-09-28
 */
@RestController
@RequestMapping("/assetFixedSelfInspection")
@SecretBody
public class SmsAssetSelfInspectionController {

    @Resource
    private SmsAssetSelfInspectionService smsAssetSelfInspectionService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;


    @ApiOperation("获取自己的自查计划")
    @GetMapping("/getMyPlanList")
    public ResponseResult getMyPlanList(@RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize,
                                        @RequestParam(value = "pageNum", defaultValue = "1")Integer pagNum,
                                        HttpServletRequest request) {
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetSelfInspectionService.getMyPlanList(userId,pagNum,pageSize);
    }

    @ApiOperation("获取自己资产自查列表")
    @GetMapping("/getSelfInspectionList")
    public ResponseResult getSelfInspectionList(@RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize,
                                                @RequestParam(value = "pageNum", defaultValue = "1")Integer pagNum,
                                                @RequestParam(value = "planId") String planId,
                                                @RequestParam(value = "assetId",required = false)String assetId,
                                                @RequestParam(value = "searchStr",required = false)String searchStr,
                                                @RequestParam(value = "assetStatus",required = false) Integer assetStatus,
                                                @RequestParam(value = "isComplete",required = false) Integer isComplete,
                                                HttpServletRequest request) {
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetSelfInspectionService.getSelfInspectionList(pagNum, pageSize,userId,planId,searchStr,assetStatus,isComplete,assetId);
    }

    @ApiOperation("完成单个物品自查")
    @PostMapping("/finishOneAsset")
    public ResponseResult finishOneAsset(HttpServletRequest request,@RequestBody SmsAssetSelfInspectionDetailReq req) {
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetSelfInspectionService.finishOneAsset(userId,req);
    }



    @ApiOperation("完成全部自查")
    @PostMapping("/finishAll")
    public ResponseResult finishAll(HttpServletRequest request,@RequestBody SmsAssetSelfInspectionPlanFinishReq finishReq) {
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetSelfInspectionService.finishAll(userId,finishReq);
    }

    @ApiOperation("获取所有的资产自查用户列表")
    @GetMapping("/getSelfInspectionUserAllList")
    public ResponseResult getSelfInspectionUserAllList(@RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize,
                                                @RequestParam(value = "pageNum", defaultValue = "1")Integer pagNum,
                                                @RequestParam(value = "planId") String planId,
                                                @RequestParam(value = "selfInspectionUserName",required = false)String selfInspectionUserName,
                                                @RequestParam(value = "isComplete",required = false) Integer isComplete) {
        return smsAssetSelfInspectionService.getSelfInspectionUserAllList(pagNum, pageSize,planId,isComplete,selfInspectionUserName);
    }

    @ApiOperation("获取指定用户下所有的资产自查列表")
    @GetMapping("/getAppointSelfInspectionAllList")
    public ResponseResult getAppointSelfInspectionAllList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                          @RequestParam(value = "pageNum", defaultValue = "1") Integer pagNum,
                                                          @RequestParam(value = "planId") String planId,
                                                          @RequestParam(value = "userId") String userId,
                                                          @RequestParam(value = "assetStatus", required = false) Integer assetStatus,
                                                          @RequestParam(value = "isComplete", required = false) Integer isComplete) {
        return smsAssetSelfInspectionService.getAppointSelfInspectionAllList(pagNum, pageSize, planId, isComplete, userId, assetStatus);
    }

}

